package cn.cmcc.online.smsapi.ui.presenter;

import android.content.Context;
import android.view.View;

import org.json.JSONObject;

import cn.cmcc.online.smsapi.ui.model.VerificationCodeData;

/**
 * Created by ZhangYifan on 2017/6/21.
 */

public class VerificationCodePresenterImpl extends VerificationCodePresenter {
    private VerificationCodeData mData;

    public VerificationCodePresenterImpl() {
    }

    @Override
    public void bind(JSONObject data) {
        super.bind(data);

        mData = new VerificationCodeData(data);
        int color = mData.getColor();
        String highInfoTtile = mData.getHighInfoTtile();
        String highInfoValue = mData.getHighInfoValue().replaceAll("\n","");
        String mainInfo = mData.getMainInfo();
        String tip = mData.getTip();

        if (highInfoTtile != null && highInfoTtile.length() > 0) {
            vista.setHighInfoTtile(highInfoTtile);
            vista.setHighTitleVisible(View.VISIBLE);
        } else {
            vista.setHighTitleVisible(View.INVISIBLE);
        }

        vista.setHighInfoValue(highInfoValue);
        vista.setHighInfoColor(color);

        vista.setHighInfoTextSize(vista.getSingleLineTextSize(highInfoValue));

        vista.setMainInfo(mainInfo);

        if (tip != null && tip.length() > 0) {
            vista.setTip("提示："+tip);
        } else {
            vista.setTip("提示：请勿泄漏给他人！");
        }
    }
}
